package zlatan_demo13_match

//匹配类型
object ClassDemo02 {
  def main(args: Array[String]): Unit = {
    val a: Any = "hadoop"

    //定义模式匹配
    val result1 = a match {
      case x: String => s"${x}是一个String类型的数据"
      case x: Int => s"${x}是一个Int类型的数据"
      case x: Double => s"${x}是一个Double类型的数据"
      case _=>"未匹配"
    }
    println(result1)
    //简写版
    val result2 = a match {
      case _: String => "String"
      case _: Int => "Int"
      case _: Double => "Double"
      case _ => "未匹配"
    }
    println(result2)
  }

}
